import request from '@/src/basic/utils/request.js'
function handleParams(param) {
  let paramsUrl = ''
  for (const item in param) {
    let val = param[item]
    let str = `${item}=${val}&`
    paramsUrl += str
  }
  paramsUrl = paramsUrl.slice(0, paramsUrl.length - 1)
  return paramsUrl
}
// /mcManagementType/businessType获取经营类型
export const businessType = async params => {
  const { data } = await request.post(`/merchant/mcManagementType/businessType?${handleParams(params)}`)
  return data
}
// /app/coupon/addCoupon添加到店卷
export const addCoupon = async params => {
 const { data } = await request.post('/merchant/app/coupon/addCoupon', params)
  return data
}
// /app/coupon/viewDetails查询到店卷详细信息
export const viewDetails = async params => {
  const { data } = await request.get(`/merchant/app/coupon/viewDetails?${handleParams(params)}`)
  return data
}
// /app/coupon/updCoupon更改信息到店卷信息
export const updCoupon = async params => {
 const { data } = await request.post('/merchant/app/coupon/updCoupon', params)
  return data
}
// /app/coupon/updShelfState 到店卷上下架
export const updShelfState = async params => {
  const { data } = await request.get(`/merchant/app/coupon/updShelfState?${handleParams(params)}`)
  return data
}